package casa.depesos.app.com.http.req;

import java.util.Map;

import casa.depesos.app.com.http.HttpReq;
import casa.depesos.app.com.http.Req;
import casa.depesos.app.com.http.ReqCallback;
import casa.depesos.app.com.http.bean.GetCodeBean;
import casa.depesos.app.com.http.parser.GetCodeParser;

public class UnReadReq implements HttpReq<GetCodeBean> {
    String type;

    public UnReadReq(String type) {
        this.type = type;
    }

    @Override
    public void req(ReqCallback<GetCodeBean> callback) {//  /app/msg/msgNotReadCount
        req("/app/communication/unreadMessageCount", new GetCodeParser(), callback);
    }

    public int req() {//  /app/msg/msgNotReadCount
        try {
            GetCodeBean bean = Req.post("/app/communication/unreadMessageCount", getParam(), getHeader(), getBody(), new GetCodeParser(), this);
            return Float.valueOf(bean.data.toString()).intValue();
        } catch (Throwable e) {
            e.printStackTrace();
            return 0;
        }
    }

    @Override
    public Map getBody() {
        Map map = HttpReq.super.getBody();
        map.put("msgCategory", type);
        return map;
    }
}
